using SmartLink.Domain.IServices;
using SmartLink.Domain.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartLink.Infrastructure.Mappers
{


    public class DictionaryConvertHelper
    {
        private static  ISysBasicServices _ISysBasicServices=new SysBasicServices(new Repository.SYS_DictionaryRepo());


        public  static string GetDescriptionByValue(string catogaryValue, int itemValue)
        {
            string itemName = "";
            List<SYS_Dictionary> dicItems = _ISysBasicServices.DictionaryList(catogaryValue);
            if (dicItems != null && dicItems.Count > 0)
            {
                var selected = dicItems.Where(item => item.DictionaryItemValue == itemValue);
                if (selected != null && selected.Count() > 0)
                    itemName = selected.ToList()[0].DictionaryItemName;
            }

            return itemName;
        }

        public static int GetValueByDesc(string catogaryValue, string itemName)
        {
            

            var itemValue = -1;
            List<SYS_Dictionary> dicItems = _ISysBasicServices.DictionaryList(catogaryValue);
            if (dicItems != null && dicItems.Count > 0)
            {
                var selected = dicItems.Where(item => item.DictionaryItemName == itemName);
                if (selected != null && selected.Count() > 0)
                    itemValue = selected.ToList()[0].DictionaryItemValue;
            }

            return itemValue;
        }


    }
}
